import React, { Suspense } from "react";
/* 
使用路由懒加载
import Home from "../page/home";
import Login from "../page/login";
import NotFound from "../page/404";
*/
import PrivateRouter from "../util/PrivateRouter";
import type { RouteObject } from "react-router-dom";


const Home = React.lazy(() => import('../page/home/index'))
const Login = React.lazy(() => import('../page/login/index'))
const NotFound = React.lazy(() => import('../page/404/index'))

export const router: RouteObject[] = [
    {
        path:'/',
        element: (
            <PrivateRouter allowed={true} redirectTo="/login">
                <Suspense fallback={<div>Loading...</div>}>
                    <Home/>
                </Suspense>
            </PrivateRouter>
        ),
    },{
        path:'/login',
        element: (
            <PrivateRouter allowed={false} redirectTo="/">
                <Suspense fallback={<div>Loading...</div>}>
                    <Login/>
                </Suspense>
            </PrivateRouter>
        ),
    },{
        path:'*',
        element: (
            <Suspense fallback={<div>Loading...</div>}>
                <NotFound/>
            </Suspense>
        ),
    }
]

export default router